package com.example.managemyself.data.database;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;
import com.example.managemyself.data.model.HealthData;
import java.util.Date;
import java.util.List;

@Dao
public interface HealthDao {
    
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long insert(HealthData healthData);
    
    @Update
    void update(HealthData healthData);
    
    @Delete
    void delete(HealthData healthData);
    
    @Query("SELECT * FROM health_data ORDER BY date DESC")
    LiveData<List<HealthData>> getAllHealthData();
    
    @Query("SELECT * FROM health_data WHERE date = :date LIMIT 1")
    LiveData<HealthData> getHealthDataByDate(Date date);
    
    @Query("SELECT * FROM health_data WHERE date = :date LIMIT 1")
    HealthData getHealthDataByDateSync(Date date);
    
    @Query("SELECT * FROM health_data ORDER BY date DESC LIMIT :days")
    List<HealthData> getRecentHealthDataSync(int days);
    
    @Query("DELETE FROM health_data WHERE date = :date")
    void deleteByDate(Date date);
} 